﻿<UserControl x:Class="TVManager.TVSeriesControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:app="clr-namespace:TVManager"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>
        <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <Grid x:Name="mainLayout" Visibility="Collapsed" AllowDrop="True" Background="White">
                <Grid.Resources>
                    <app:SeasonCountConverter x:Key="seasonCountConverter" />
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="300" />
                </Grid.ColumnDefinitions>

                <StackPanel Orientation="Horizontal"  HorizontalAlignment="Right" Grid.ColumnSpan="2" Grid.Row="0">
                    <Button x:Name="refreshFilesButton" Content="Refresh Files for Series" Margin="3" />
                    <Button x:Name="updateSeriesButton" Content="Update Series" Margin="3" />
                </StackPanel>


                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Label Grid.Column="0" Grid.Row="2" Content="First Aired:"  />
                    <Label Grid.Column="0" Grid.Row="3" Content="Air Day:"  />
                    <Label Grid.Column="0" Grid.Row="4" Content="Air Time:"  />
                    <Label Grid.Column="0" Grid.Row="5" Content="Runtime:"  />
                    <Label Grid.Column="0" Grid.Row="6" Content="Network:"  />
                    <Label Grid.Column="0" Grid.Row="7" Content="Genres:"  />


                    <TextBlock Grid.ColumnSpan="2" Grid.Row="0" Text="{Binding Path=SeriesName}" FontSize="20" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.ColumnSpan="2" Grid.Row="1" Text="{Binding Path=Overview}" TextWrapping="Wrap" Margin="3,3,3,15" />
                    <TextBlock Grid.Column="1" Grid.Row="2" x:Name="firstAiredTextBlock" VerticalAlignment="Center"  />
                    <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Path=AirsDayOfWeek}" VerticalAlignment="Center"  />
                    <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Path=AirsTime}" VerticalAlignment="Center"  />
                    <TextBlock Grid.Column="1" Grid.Row="5" x:Name="runtimeTextBlock" VerticalAlignment="Center" />
                    <TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding Path=Network.Name}" VerticalAlignment="Center"  />
                    <TextBlock Grid.Column="1" Grid.Row="7" x:Name="genresTextBlock" VerticalAlignment="Center" />

                    <Grid x:Name="seasonsGrid" Margin="3,10,3,3" Grid.ColumnSpan="2" Grid.Row="8">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Seasons" FontWeight="Bold" Margin="3" />
                        <ListBox x:Name="seasonsListBox" Margin="3" MaxHeight="250" MinHeight="75">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Season " />
                                        <TextBlock Text="{Binding SeasonNumber}" />
                                        <TextBlock Text="{Binding Episodes,Converter={StaticResource seasonCountConverter}}" />
                                    </StackPanel>

                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <CheckBox Grid.Row="2" x:Name="displaySeasonsCheckbox" Content="Hide Seasons without episode files?" TextBlock.FontSize="10" />
                        <Button Grid.Row="2" x:Name="viewSeasonButton" Content="View Season" HorizontalAlignment="Right"/>
                    </Grid>

                    <Grid x:Name="actorsGrid" Margin="3,10,3,3" Grid.ColumnSpan="2" Grid.Row="9">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Actors" FontWeight="Bold" Margin="3" />
                        <ScrollViewer Grid.Row="1" BorderBrush="Black" BorderThickness="2" VerticalScrollBarVisibility="Auto" Margin="3" MaxHeight="600" MinHeight="75">
                            <ItemsControl x:Name="actorsListBox">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Margin="3">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="200" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>

                                            <Image Grid.Column="0" Source="{Binding ImageLocation}" />
                                            <StackPanel Grid.Column="1" Margin="2">
                                                <TextBlock Text="{Binding Person.PersonName}" FontSize="15" FontWeight="Bold" />
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="as " />
                                                    <TextBlock Text="{Binding Role}" />
                                                </StackPanel>
                                            </StackPanel>

                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Grid>
                </Grid>

                <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1">
                    <Grid>
                        <TextBlock Text="Loading..." Margin="10" />
                        <Image x:Name="posterImage" Margin="5" />
                    </Grid>
                    <Button x:Name="changePosterButton" Content="Change Poster Image" Tag="poster" Margin="3" HorizontalAlignment="Center" />

                    <Grid>
                        <TextBlock Text="Loading..." Margin="10" />
                        <Image x:Name="bannerImage" Margin="5" />
                    </Grid>
                    <Button x:Name="changeBannerButton" Content="Change Banner Image" Tag="series" Margin="3" HorizontalAlignment="Center" />

                    <Grid>
                        <TextBlock Text="Loading..." Margin="10" />
                        <Image x:Name="fanartImage" Margin="5" />
                    </Grid>
                    <Button x:Name="changeFanartButton" Content="Change Fan Art Image" Tag="fanart" Margin="3" HorizontalAlignment="Center" />
                </StackPanel>

            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
